-
Notifications
You must be signed in to change notification settings - Fork 50
feat(mcp): add natural language configuration tools #1610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(mcp): add natural language configuration tools #1610
Conversation
Add three new MCP tools that enable AI assistants to configure Robocop through natural language. Users can describe what they want (e.g., "allow longer lines" or "disable naming checks") and the AI generates the appropriate TOML configuration. New tools: - get_config_context: Provides rule catalog and instructions for LLM processing - parse_config_response: Validates LLM JSON response into config suggestions - apply_configuration: Writes validated config to TOML files Key features: - Support for all config formats (pyproject.toml, robot.toml, robocop.toml) - Handles rule configuration, enable/disable, and scalar options - Multi-section support (common, lint, format) - Intelligent TOML merging preserving existing configuration - Conflict detection (e.g., enabling and disabling same rule) - Deprecated rule warnings - Preview-by-default workflow (apply_configuration is explicit)
| NESTED_CONFIG_SECTIONS = frozenset(("lint", "format")) | ||
|
|
||
| # Robocop configuration file names | ||
| CONFIG_NAMES = frozenset(("robocop.toml", "pyproject.toml", "robot.toml")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should CONFIG_NAMES be imported from config.py? In case there is change in one, so it does update the other.
| """ | ||
| self._ensure_populated() | ||
| assert self._by_id is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep assert here? It looks like it can't be None as long as _ensure_populated is executed anyway
| description = "" | ||
| if rule.docs: | ||
| first_line = rule.docs.strip().split("\n")[0].strip() | ||
| description = first_line[:200] if len(first_line) > 200 else first_line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read it correctly, it documentation is shorter than 200 we set description to first_line only? Why is that?
| "description": description, | ||
| "severity": rule.severity.value, | ||
| "enabled": rule.enabled, | ||
| "deprecated": rule.deprecated, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the deprecated rule be filtered out? For example user ask for rule that does X, and we have rule for that but it's deprecated. Ideally it shouldn't try to configure it.
| return str(list(val)[:3]) + "..." if len(val) > 3 else str(list(val)) | ||
| return str(val) | ||
| except (TypeError, ValueError): | ||
| return "(factory)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does (factory) means in this context?
|
Did you saw my comments? If youre busy its fine, but wanted to make sure I didnt bury the notifications when approving the changes |
Add three new MCP tools that enable AI assistants to configure Robocop through natural language. Users can describe what they want (e.g., "allow longer lines" or "disable naming checks") and the AI generates the appropriate TOML configuration.
New tools:
Key features: